import service from '../service/api'
import { parseStrEmpty } from "../utils/bigwolf";
export function listUser(query) {
  return service({
    url: '/system/user/list',
    method: 'get',
    params: query
  })
}
// 查询用户详细
export function getUser(userId) {
    return service({
      url: '/system/user/' + parseStrEmpty(userId),
      method: 'get'
    })
  }

  // 新增用户
export function addUser(data) {
  return service({
    url: '/system/user',
    method: 'post',
    data: data
  })
}

// 修改用户
export function updateUser(data) {
  return service({
    url: '/system/user',
    method: 'put',
    data: data
  })
}

// 删除用户
// 导出一个函数，用于删除用户
export function delUser(userId) {
  // 调用service函数，传入url和method参数
  return service({
    url: '/system/user/' + userId,
    method: 'delete'
  })
}



// 查询部门下拉树结构
export function deptTreeSelect() {
    return service({
      url: '/system/user/deptTree',
      method: 'get'
    })
  }


  // 用户状态修改
export function changeUserStatus(userId, status) {
    const data = {
      userId,
      status
    }
    return service({
      url: '/system/user/changeStatus',
      method: 'put',
      data: data
    })
  }

  // 查询授权角色
export function getAuthRole(userId) {
  return service({
    url: '/system/user/authRole/' + userId,
    method: 'get'
  })
}

// 保存授权角色
export function updateAuthRole(data) {
  return service({
    url: '/system/user/authRole',
    method: 'put',
    params: data
  })
}

// 用户密码重置
export function resetUserPwd(userId, password) {
  const data = {
    userId,
    password
  }
  return service({
    url: '/system/user/resetPwd',
    method: 'put',
    data: data
  })
}
